$(function(){
	
	//投资进度
	var ratio = parseFloat($("#proYesAmount").val())/parseFloat($("#Amount").val());
	var result = parseFloat(150.818)*parseFloat(ratio);
	var process = Math.round(result*100)/100 + 16;
	$("#path").attr("style","stroke-dasharray:"+process+"px, 150.818px; stroke-dashoffset:15.818px")
	
	marquee_control(" .marquee .marquee-list", 30, ".marquee .prev", ".marquee .next");
	$("a[rel=marquee-img]").fancybox({
	    'transitionIn':'none',
	    'transitionOut':'none',
	    'titlePosition':'over',
	    'titleFormat':function(title, currentArray, currentIndex, currentOpts) {
		 	return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
});

$(".sureInvest").click(function(){
	var pid = $("#pidAjax").val();
	var investAmount = $("#investAmount").val();
	var payPwd = $("#payPwdInput").val();
	var lid = $("#selectCoupon").val();
	
	if($.trim(payPwd).length == 0){
		layer.msg("交易密码不能为空");
		return false;
	}else{
		var userPayPwd = $("#userPayPwd").val();
		if(userPayPwd != md5(md5(payPwd))){
			layer.msg("交易密码不正确");
			return false;
		}
	}
	
	$(".sureInvest").attr("disabled",true);
	$.ajax({
		url:g_requestContextPath + "/p/doInvest",
		type:"post",
		data:{
			"pid":pid,
			"investAmount":investAmount,
			"lid":lid,
			"payPassWord":md5(md5(payPwd)),
			"token":$("#tokenHidden").val()
		},
		dataType:"json",
		success:function(data){
			if(data.head.status == "SUCCESS"){
				layer.confirm(data.head.memo, {
					  btn: ['确定'] //按钮
					}, function(){
					  window.location.reload();
					}, function(){
						
					});
			}else{
				layer.msg(data.head.memo);
				$(".sureInvest").removeAttr("disabled");
			}
		},
		error:function(data){
			if('isSubmitting' == data){
				layer.msg("请勿重复提交，您可刷新页面重试");
			}
		}
		
	});
	
});